<?php

namespace app\common\model;
use think\Model;

class MyPackage extends Model
{
    public static function getRows($map = [])
    {
        $rows =  self::alias('p')
            ->join('draw d','d.id=p.key','LEFT')
            ->where($map)
            ->field('p.num,p.type,p.key,d.name,d.img')
            ->order('p.type desc')
            ->select();
        foreach ($rows as $k => $v){

            switch ($v['type']){
                case 1://礼物
                    $v['name'] = getGiftName($v['key']);
                    $v['img'] = getGiftImg($v['key']);
                    break;
                case 2://道具卡 预留
                    break;
                case 3://装饰 预留
                    break;
                case 4: //铜宝箱
                    if (\app\api\controller\Base::getExplain('boxAct') === 'true'){
                        $v['num']  = 999;
                    }
                    $v['name'] = '铜宝箱';
                    $v['img']  = 'http://file.mengpaxing.com/69800201904191404029202.png';
                    break;
                case 5: //银宝箱
                    $v['name'] = '银宝箱';
                    if (\app\api\controller\Base::getExplain('boxAct') === 'true'){
                        $v['num']  = 999;
                    }
                    $v['img']  = 'http://file.mengpaxing.com/b4317201904191404286835.png';
                    break;
                case 6: //金宝箱
                    $v['name'] = '金宝箱';
                    if (\app\api\controller\Base::getExplain('boxAct') === 'true'){
                        $v['num']  = 999;
                    }
                    $v['img']  = 'http://file.mengpaxing.com/4671f201904191404395945.png';
                    break;
                default:
                    $v['name'] = '';
                    $v['img']  = '';
                    break;
            }
            $v['img'] = getThumb($v['img'],300);
        }
        return $rows;
    }
}